package com.topfinance.cnaps2.service.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.topfinance.cnaps2.dto.XMLMsgDto;
import com.topfinance.cnaps2.ebo.TblResendEbo;
import com.topfinance.cnaps2.service.ITblResendManager;
import com.topfinance.frame.dao.HibernateEntityDao;
import com.topfinance.frame.exception.AppException;

/**
 * 该类自动实现了dao的一般方法，如add, remove, update
 * 在service中出现的大部分情况下是在向后台提交数据前的处理(如校验)及获取后台数据后的处理等
 * @author
 *
 */

public class TblResendManagerImpl extends HibernateEntityDao<TblResendEbo> implements ITblResendManager {

	private static final Log log = LogFactory.getLog(TblResendManagerImpl.class);

	public void addTblResnd(TblResendEbo o) throws AppException{
    	save(o);
    }
	
	public void editTblResnd(TblResendEbo o) throws AppException{
    	saveOrUpdate(o);
    }
	
	//获得报文重发
	public TblResendEbo getTblResnd(String uid) throws AppException{
		return (TblResendEbo)get(uid);
	}

	public void deleteTblResnd(TblResendEbo o) throws AppException{
		removeById(o.getClass(),o.getAuditId());
    }

	//获得报文重发列表
	public List getAllTblResendList() throws AppException{
		//String hql = " from TblResendEbo t " ;
		String hql = "select new com.topfinance.cnaps2.ebo.TblResendEbo(";
		hql += "t.resendkey, t.auditId, t.status, t.ts, t.expiration,t.inportName, t.retryCount, t.direction)";
		hql += " from TblResendEbo t";
		String where = "";
		List<Object> paramList = new ArrayList<Object>();
		if (isNotBlank(where)) {
			where = " where " + where;
		}
		hql = hql + where;
		return find(hql,paramList.toArray());		
	}
	
}
